package com.wish.finance.controller;


import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wish.common.core.usconfig.common.MsgResult;
import com.wish.finance.entity.vo.CwDetailVo;
import com.wish.finance.entity.vo.DealPerDayVo;
import com.wish.finance.entity.vo.OutDetailsVo;
import com.wish.finance.service.ITCwHailianDealPerDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 海链财务报表(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入) 前端控制器
 * </p>
 *
 * @author benjamin
 * @since 2022-04-01
 */
@RestController
@RequestMapping("/hailian")
public class TCwHailianDealPerDayController {

    @Autowired
    ITCwHailianDealPerDayService itCwHailianDealPerDayService;

    @GetMapping("/stats")
    public MsgResult stats(DealPerDayVo qv) {
        DealPerDayVo dealPerDayVo = itCwHailianDealPerDayService.stats(qv);
        return MsgResult.succeed(dealPerDayVo);
    }

    @GetMapping("/statsList")
    public MsgResult statsList(DealPerDayVo qv) {
        PageHelper.startPage(qv.getPageNum(), qv.getPageSize());
        List<DealPerDayVo> list = itCwHailianDealPerDayService.statsList(qv);
        PageInfo<DealPerDayVo> pg = new PageInfo<DealPerDayVo>(list);
        return MsgResult.succeed(pg);
    }

    @GetMapping("/cwDetails")
    public MsgResult cwDetails(CwDetailVo qv) {
        qv.setQvDate(DateUtil.offsetDay(qv.getQvDate(), 1));
        PageInfo<CwDetailVo> pg = itCwHailianDealPerDayService.cwDetails(qv);
        return MsgResult.succeed(pg);
    }

    @GetMapping("/countAmount")
    public MsgResult countAmount(CwDetailVo qv) {
        qv.setQvDate(DateUtil.offsetDay(qv.getQvDate(), 1));
        CwDetailVo countAmount = itCwHailianDealPerDayService.countAmount(qv);
        return MsgResult.succeed(countAmount);
    }

}
